package com.baizhi.app;

import com.baizhi.po.VideoPO;
import com.baizhi.service.VideoService;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;

//@CrossOrigin(origins = "http://localhost:8989,http://192.168.9.193:8989")
@RestController
@RequestMapping("app")
public class AppController {

    /**
     {
        "message": "查询成功",
        "status": "100",
        "data": [
             {
                 "id": "a11282389568441fa166ebedef03e530",
                 "videoTitle": "人民的名义",
                 "cover": "http://q40vnlbog.bkt.clouddn.com/1578650041065_人民的名义.jpg",
                 "path": "http://q3th1ypw9.bkt.clouddn.com/1578650041065_人民的名义.mp4",
                 "uploadTime": "2020-01-30",
                 "description": "人民的名义",   视频数据

                "likeCount": 0,    查询点赞表数据

                "cateName": "Java",  类别数据

                 "userPhoto":"http://q40vnlbog.bkt.clouddn.com/1.jpg"  用户数据

                    类别     视频    用户
             },
             {
                 "id": "2c4a179d87684c669abd0e2fb1e66dc4",
                 "videoTitle": "抖音视频",
                 "cover": "http://q40vnlbog.bkt.clouddn.com/1578650216541_抖音视频.jpg",
                 "path": "http://q3th1ypw9.bkt.clouddn.com/1578650216541_抖音视频.mp4",
                 "uploadTime": "2020-01-23",
                 "description": "抖音视频",
                 "likeCount": 0,
                 "cateName": "Java",
                 "userPhoto":"http://q40vnlbog.bkt.clouddn.com/1.jpg"
             },
             {
                 "id": "55af1db8af21410691d154f61b245be5",
                 "videoTitle": "动画",
                 "cover": "http://q40vnlbog.bkt.clouddn.com/1578650435020_动画.jpg",
                 "path": "http://q3th1ypw9.bkt.clouddn.com/1578650435020_动画.mp4",
                 "uploadTime": "2020-01-08",
                 "description": "动画",
                 "likeCount": 2,
                 "cateName": "Java" ,
                 "userPhoto":"http://q40vnlbog.bkt.clouddn.com/1.jpg"
             }
         ]
     }

    * */

    @Resource
    VideoService videoService;

    @RequestMapping("queryByReleaseTime")
    public HashMap<String, Object> queryByReleaseTime(){

        List<VideoPO> videoPOList = videoService.queryByReleaseTime();

        HashMap<String, Object> map = new HashMap<>();

        map.put("message","查询成功");
        map.put("status",100);
        map.put("data",videoPOList);

        return map;
    }
}
